//
//  AccountListCell.swift
//  MT
//
//  Created by 陈悦 on 2020/5/8.
//  Copyright © 2020 张强. All rights reserved.
//

import UIKit
import MTCategory

class AccountListCell: UITableViewCell {

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    var titleStr: String = "" {
        didSet {
            titleLabel.text = titleStr
        }
    }
    
    var valueStr: String = "" {
        didSet {
            detailLabel.text = "总计:\(valueStr)点券"
        }
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

    lazy var titleLabel: UILabel = {
        let l = UILabel()
        l.textColor = UIColor(hex:0x1d1a1a)
        l.font = PingFangSCMediumFont(16)
        return l
    }()
    
    lazy var detailLabel: UILabel = {
        let l = UILabel()
        l.textColor = UIColor(hex:0x9b9b9b)
        l.font = PingFangSCMediumFont(12)
        l.textAlignment = .right
        return l
    }()
    
    lazy var rightIcon: UIImageView  = {
        let imgView = UIImageView()
        imgView.image = UIImage(named: "icon_right_gary")
        return imgView
    }()
    
    lazy var lineView: UIView = {
        let v = UIView()
        v.backgroundColor = UIColor(hex:0xd8d8d8)
        return v
    }()
    
    
    class func reuseIdentity() -> String {
        return "AccountListCellID"
    }
    
    func bind(model: MTLuckyReportSubModel) {
            
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupUI()
        makeConstraint()
        contentView.backgroundColor = UIColor.theme.background
        backgroundColor = UIColor.theme.background
    }
    
    private func setupUI() {
        contentView.addSubview(titleLabel)
        contentView.addSubview(detailLabel)
        contentView.addSubview(rightIcon)
        contentView.addSubview(lineView)
    }
    
    private func makeConstraint() {
        titleLabel.snp.makeConstraints { (make) in
            make.centerY.equalTo(contentView)
            make.left.equalTo(contentView).offset(10)
        }
        
        rightIcon.snp.makeConstraints { (make) in
            make.right.equalTo(contentView).offset(-10)
            make.centerY.equalTo(contentView)
            make.width.height.equalTo(15)
        }
        
        detailLabel.snp.makeConstraints { (make) in
            make.centerY.equalTo(contentView)
            make.right.equalTo(rightIcon.snp.left)
            make.width.equalTo(300)
        }

        lineView.snp.makeConstraints { (make) in
            make.left.bottom.right.equalToSuperview()
            make.height.equalTo(0.5)
        }
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }

}
